<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
<style type="text/css">
li {
	list-style: none;
}
</style>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;贷后业务>结清-法务申请</span>
		</div>
		<div class="buttonfixed">
	       <button type="button" class="btn dpbtn_blue btnaplly" onclick="update();">保存提交</button>
	    </div>
		<div class="ibox-content ibox-con">
			<form class="form-horizontal" id="commentForm">
				<%@include file="/jsp/comm_yw_info_include.jsp"%>
				<div class="business-manwife">结清信息</div>
				<div class="business-padding">
					<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
						<tr>
							<td align="right"><label class="control-label np">结清类型：</label>
							</td>
							<td><input type="text" class="form-control" readonly="readonly" id="typeSettleDisplay"/></td>
							<td align="right"><label class="control-label np">违约金：</label>
							</td>
							<td><input class="form-control" placeholder="违约金(必填)" required="required" type="number" id="amountPenalty" value="0" name="amountPenalty" aria-required="true" /></td>
						</tr>
						
						<tr>
							<td align="right"><label class="control-label np">收到时间：</label>
							</td>
							<td><input class="laydate-icon form-control" onclick="laydate()"   placeholder="收到时间(必填)" required="required" type="text" id="timeReceive"  name="" aria-required="true" /></td>
						</tr>
						<tr>	
							<td align="right" valign="top"><label class="control-label np">备注：</label> </td>
							<td colspan="3">
								<textarea id="remarks" rows="" cols="5" class="form-control"></textarea>
							</td>
						</tr>
					</table>
				</div>

				<div class="business-manwife">经办信息</div>
				<div class="padding-nono">
					<table cellpadding="0" cellspacing="0" border="0"
						class="buyinfor-table">
						<tr>
							<td align="right"><label class="control-label np">经办人：</label>
							</td>
							<td><input class="form-control" type="text" id="creatorName"
								name="creatorName" readonly="readonly"
								value="${current_user_key.uname}" /></td>
							<td align="right"><label class="control-label np">经办时间：</label>
							</td>
							<td><input id="created" name="created" placeholder="经办时间(必填)" 
								class="form-control" readonly="readonly"/></td>
						</tr>
					</table>

				</div>
			</form>
		</div>

	</div>

	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>

	<!-- layerDate plugin javascript -->
	<script type="text/javascript"
		src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>

	<!-- custom js -->
	<%@include
		file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>
	<script type="text/javascript" src="${basePath}/js/commonvalidate.js"
		charset="utf-8"></script>
	<!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
	<script type="text/javascript">
	
	    $(function(){ 
	        $("#commentForm").validate({
	        	 rules: {
	        		 amountPenalty:{
	                   		allMoney: true,
	                 	},
	                },
	                messages: {
	                	amountPenalty:{
	                		allMoney: "金额错误",
	                 },
	             },
	            //重写showErrors
	            showErrors: function (errorMap, errorList) {
	                
	                $.each(errorList, function (i, v) {
	                    layer.tips(v.message, v.element, { time: 1500 });
	                    return false;
	                });  
	            },
	            /* 失去焦点时验证 */
	            onfocusout: function(element) { $(element).valid(); },
	            /*  键盘抬起不验证 */
	            onkeyup:false,
	        });
	        
	        var date = new Date();
		    document.getElementById("created").value = date.format("yyyy-MM-dd h:m:s");
	        
	        initData();
	 	});
	    
	    var  initData = function()
	    {
	    	$.dpAjax({
	    		url:'${basePath}/DhSettleController/getById',
	    		data:{"id":$.getUrlData("settleId")},
   				success: function(datas){
	    			  if(datas.flag == "100100")
					  {
	    				  $("#typeSettleDisplay").val($.getUrlData("typeSettleDisplay"));
	    				  var datas = datas.result;
	    				  $('#amountPenalty').val(datas.amountPenalty);
	    				  $('#timeReceive').val(datas.timeReceive);
	    				  $('#remarks').val(datas.remarks);
						  return;
					  }
					  layer.msg(datas.message, {icon: 6});
                }
	    	});
	    }
	    
		var update = function(){
			var validstatus = $("#commentForm").valid();
   	    	if(validstatus)
   	    	{
				var data={};
				data.id=$.getUrlData("settleId");
				data.amountPenalty=$("#amountPenalty").val();
				data.busiId=$.getUrlData("busiId");
				data.cusId=$.getUrlData("cusId");
				data.timeReceive=$("#time_receive").val();
				data.remarks=$("#remarks").val();
				layer.confirm('您确认要保存提交吗？', {
		  			  btn: ['确定','取消'] //按钮
				},function(){
					layer.closeAll();
					$.dpAjax({
			    		url:'${basePath}/DhSettleController/modify',
			    		data:data,
		   				success: function(datas){
			    			  if(datas.flag == "100100")
							  {
			    				  layer.msg('执行成功！', {icon: 6});
								  return;
							  }
							  if(datas.flag == "100200")
			                  {
								  $.fn.showDatas({"datas":datas});
			                	  return;
			                  }
		                }
			    	});
				});	
   	    	}	
		} 
    </script>
</body>
</html>
